package com.atguigu.day17.test01;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author fenge
 */
public class Test01 {
    public static void main(String[] args) {
        ArrayList<String> arrayList = new ArrayList<>();
        String[] point = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
        String[] color = {"方块","黑桃","梅花","红心"};
        String[] joker = {"大王","小王"};

        for (int i = 0; i < color.length; i++) {
            for (int j = 0; j < point.length; j++) {
                arrayList.add(color[i]+point[j]);
            }
        }
        arrayList.add(joker[0]);
        arrayList.add(joker[1]);
//
//        for (String s : arrayList) {
//            System.out.println(iterator.next().toString());
//        }

        ArrayList<String> a1 = new ArrayList<>();
        ArrayList<String> a2 = new ArrayList<>();
        ArrayList<String> a3 = new ArrayList<>();
        ArrayList<String> a4 = new ArrayList<>();
        for (int i = 0; i < 11; i++) {
            rand(arrayList,a1);
            rand(arrayList,a2);
            rand(arrayList,a3);
            rand(arrayList,a4);
        }
        Iterator iterator1 = a1.iterator();
        for (String s : a1) {
            System.out.print(iterator1.next().toString()+",");
        }
        System.out.println("\n*******************");

        Iterator iterator2 = a2.iterator();
        for (String s : a2) {
            System.out.print(iterator2.next().toString()+",");
        }
        System.out.println("\n*******************");
        Iterator iterator3 = a3.iterator();
        for (String s : a3) {
            System.out.print(iterator3.next().toString()+",");
        }
        System.out.println("\n*******************");
        Iterator iterator4 = a4.iterator();
        for (String s : a4) {
            System.out.print(iterator4.next().toString()+",");
        }
        System.out.println("\n*******************");
        Iterator iterator = arrayList.iterator();
        for (String s : arrayList) {
            System.out.print(iterator.next().toString()+",");
        }

    }
    static ArrayList rand(ArrayList main,ArrayList sub){
        int length = main.size();
        int randomnum = (int)(Math.random()*length-1);
        sub.add(main.get(randomnum));
        main.remove(randomnum);
        return sub;
    }
}
